﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using MessageBusConn;

namespace Common.Service
{
    public class BLL
    {
        public List<tbcontrol> List()
        {
            return tbcontrol.Fetch("");
        }

        public tbcontrol Get(string id)
        {
            return tbcontrol.FirstOrDefault(" where id=@0", id);
        }

        public bool Save(tbcontrol tb)
        {
            if (string.IsNullOrEmpty(tb.ID))
            {
                tb.ID = Guid.NewGuid().ToString();
                tb.IsActive = 1;
                tb.CreateDate = DateTime.Now;
                tb.UpdateDate = DateTime.Now;
                tb.Insert();
                BusHelper.Bind();
                return true;
            }
            else
            {
                tb.UpdateDate = DateTime.Now;
                var rows = tb.Update();
                BusHelper.Bind();
                return rows > 0;
            }
        }
    }
}
